#include "PhysicCollisionDetection.h"

PhysicCollisionDetection::PhysicCollisionDetection(){};
PhysicCollisionDetection::~PhysicCollisionDetection(){};

void PhysicCollisionDetection::Update(LinkedList<PhysicRigidBody *> *a_RigidBodyList){
	int t_size = a_RigidBodyList->Get_Size();
	for(int i = 0; i < t_size; i++){
		PhysicRigidBody *t_PhysicRigidBody = a_RigidBodyList->Get_Data(i);
		for(int j = 0; j < t_size; j++){
			PhysicRigidBody *t_PhysicRigidBody2 = a_RigidBodyList->Get_Data(j);
			if(t_PhysicRigidBody == t_PhysicRigidBody2){
				continue;
			}
			bool t_insert = true;
			for(int k = 0; k < t_PhysicRigidBody->m_PhysicObject->m_PhysicObjectList.Get_Size(); k++){
				if(t_PhysicRigidBody2->m_PhysicObject
					== (*t_PhysicRigidBody->m_PhysicObject->m_PhysicObjectList.Get_Data(k))){
						t_insert = false;
						break;
				}
			}
			if(t_insert){
				t_PhysicRigidBody->m_PhysicObject->m_PhysicObjectList.Insert_ToEnd((&t_PhysicRigidBody2->m_PhysicObject));
			}
		}
	}
};